<div class="xiu-container">
    <div class="ss-search">
        <div class="ss-search-bar clearfix">
            <input type="text" name="word" value="" autocomplete="off" placeholder="找艺人／搜ID号"
                   class="search-content-input">
            <a class="search-button" href="javascript:;" id="J_This_Search">搜索</a>
        </div>
        <div class="ss-search-line"></div>
        <div class="ss-search-cont clearfix">
            <div class="search-count-s" id="J_Search_Anchor_Total">
                搜索"<span class="search_hotkey s-mark"></span>"有 <em class="s-mark"></em>个结果
            </div>
            <div class="search-count-c">
                <h2 class="" id="J_Search_Icon_Title"></h2>
                <ul class="s-livelist" id="J_Global_Search_ListInfo">

                </ul>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $('#J_This_Search').on('click',function () {
            var This_key=$.trim($('input[name="word"]').val());
            if(!This_key){
                $.CommonMain.Modal_Tip("请输入搜索条件", {Timeout: 2000});
                return;
            }
            $(this).attr('href', '/search?key='+This_key);
        });
        var values = _PageData.value;

        var _ThisPage = {
            PageParm: {
                P_Get: true,
                Loading: false, //加载中
                Total: 0,       //总条数
                MaxCode: "",    //MaxCode
                Start: 0,       //开始
                Length: 15      //页长度
            }
        };
        $.ajax({
            url: '/ajax/user.user-anchor.page',
            type: 'post',
            dataType: 'json',
            data: {
                Cache: true,
                P_Get: _ThisPage.PageParm.P_Get,
                P_Total: _ThisPage.PageParm.Total,
                P_MaxCode: _ThisPage.PageParm.MaxCode,
                iDisplayStart: _ThisPage.PageParm.Start,
                iDisplayLength: _ThisPage.PageParm.Length,
                F_SValue: values
            },
            success: function (data) {
                _ThisPage.PageParm.Loading = false;
                _ThisPage.PageParm.P_Get = false;
                if (data.flag !== 0) {
                    $.CommonMain.Modal_Tip(data.msg + "(" + data.flag + ")", {Timeout: 2000});
                    return;
                }
                _ThisPage.PageParm.Total = data.iTotalRecords;
                _ThisPage.PageParm.MaxCode = data.sMaxCode;
                _ThisPage.PageParm.Start += _ThisPage.PageParm.Length;

                var _html = '';
                if (data.iTotalRecords == 0) {
                    $("#J_Search_Anchor_Total").empty().append(' <img src="'+ _VirtualPath.Static +'main/image/common/s-face.png"/> 抱歉，没有找到"<span class="search_hotkey s-mark">'+values+'</span>的相关内容');
                    $('#J_Search_Icon_Title').attr('class','s-icon-title');
                    _ThisPage.PageParm.Length=6;
                    _ThisPage.PageParm.Start=0
                    $.ajax({
                        url: '/ajax/user.user-anchor.page',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            Cache: true,
                            P_Get: _ThisPage.PageParm.P_Get,
                            P_Total: _ThisPage.PageParm.Total,
                            P_MaxCode: _ThisPage.PageParm.MaxCode,
                            iDisplayStart: _ThisPage.PageParm.Start,
                            iDisplayLength: _ThisPage.PageParm.Length,
//                      F_Status: "1",
                        },
                        success: function (data) {
                            _ThisPage.PageParm.Loading = false;
                            _ThisPage.PageParm.P_Get = false;
                            if (data.flag !== 0) {
                                $.CommonMain.Modal_Tip(data.msg + "(" + data.flag + ")", {Timeout: 2000});
                                return;
                            }
                            _ThisPage.PageParm.Total = data.iTotalRecords;
                            _ThisPage.PageParm.MaxCode = data.sMaxCode;
                            _ThisPage.PageParm.Start += _ThisPage.PageParm.Length;
                            var _html = '';
                            _.forEach(data.aaData, function (ThisValue, n) {
                                var _LiveState = (ThisValue.Live) ? (ThisValue.Live_IsMobile)? '<i class="living"></i>' : '<i class="living-mobile"></i>' : '';
                                _html += '<li>' +
                                         _LiveState +
                                        '<div class="v-pic">' +
                                        '<a href="/room/' + ThisValue.User_ID + '">' +
                                        '<img alt="" src="' + $.Common.ImageBind.UserCover.fnURL(ThisValue.User_ID, "146.146") + '">' +
                                        '</a>' +
                                        '</div>' +
                                        '<div class="info">' +
                                        '<p class="nickname">' +
                                        '<a href="javascript:;">' + ThisValue.NickName + '</a>' +
                                        '<i class="ico-lev">' +
                                        '<img src="' + _VirtualPath.Static + 'main/image/common/level/anchor/' + ThisValue.Anchor_Level + '.png">' +
                                        '</i>' +
                                        '</p>' +
                                        '<p class="online">ID：<em>' + ThisValue.User_ID + '</em>' +
                                        '</p>' +
                                        '</div>' +
                                        '</li>';
                            });
                            $('#J_Global_Search_ListInfo').empty().append(_html);
                        }
                    });
                } else {
                    $("#J_Search_Anchor_Total").empty().append('搜索<span class="search_hotkey s-mark">'+values+'</span>有 <em class="s-mark">'+data.iTotalRecords+'</em>个结果');
                    _.forEach(data.aaData, function (ThisValue, n) {
                        var _LiveState = (ThisValue.Live) ? (ThisValue.Live_IsMobile)? '<i class="living living-mobile"></i>' : '<i class="living"></i>' : '';
                        _html += '<li>' +
                                 _LiveState +
                                '<div class="v-pic">' +
                                '<a href="/room/' + ThisValue.User_ID + '">' +
                                '<img alt="" src="' + $.Common.ImageBind.UserCover.fnURL(ThisValue.User_ID, "146.146") + '">' +
                                '</a>' +
                                '</div>' +
                                '<div class="info">' +
                                '<p class="nickname">' +
                                '<a href="javascript:;">' + ThisValue.NickName + '</a>' +
                                '<i class="ico-lev">' +
                                '<img src="' + _VirtualPath.Static + 'main/image/common/level/anchor/' + ThisValue.Anchor_Level + '.png">' +
                                '</i>' +
                                '</p>' +
                                '<p class="online">ID：<em>' + ThisValue.User_ID + '</em>' +
                                '</p>' +
                                '</div>' +
                                '</li>';
                    });

                }
                $('#J_Global_Search_ListInfo').empty().append(_html);
            }
        });
    })
</script>